package com.kx.yooli.kx.wechat.mapper.paycard;

import com.kx.yooli.kx.wechat.po.paycard.WechatPaycard;
import com.kx.yooli.kx.wechat.po.user.UserInfo;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface WechatPaycardMapper extends BaseMapper<WechatPaycard> {
    @Select("select * from wechat_paycard where c_cardNo = #{idCard}")
    List<WechatPaycard> getPaycardListByIdCard(@Param("idCard") String idCard);
    default List<WechatPaycard> getPaycardListByIdCardCopy(String idNo){
        return selectListByQuery(QueryWrapper.create()
                .select()
                .from("wechat_paycard")
                .where("c_idNo="  +"'"+ idNo+"'"));
    };

    default List<WechatPaycard> getPaycardListByCardNo(String cardNo){
        return selectListByQuery(QueryWrapper.create()
                .select()
                .from("wechat_paycard")
                .where("c_cardNo=" +"'"+ cardNo+"'"));
    };

    default boolean updateUserBank(WechatPaycard paycard){
        return UpdateChain.of(WechatPaycard.class)
                .setRaw(WechatPaycard::getcCardNo,paycard.getcCardNo())
                .where(WechatPaycard::getcId).eq(paycard.getcId()).update();
    }


}
